﻿#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os

import tornado.web
import tornadio
import tornadio.router
import tornadio.server

import connection
import handler 

class Application(tornado.web.Application):
    def __init__(self):
        handlers = [ (r"/", handler.IndexHandler), tornadio.get_router(connection.ClientConnection).route()]
        settings = dict(
            static_path = os.path.join( os.path.dirname(__file__), "static" ),
            template_path = os.path.join( os.path.dirname(__file__), "template" ),
            enabled_protocols = ['websocket','flashsocket','xhr-multipart','xhr-polling'],
            flash_policy_port = 843,
            flash_policy_file = os.path.join( os.path.dirname(__file__), 'flashpolicy.xml'),
            socket_io_port = 8001,
        )
        tornado.web.Application.__init__(self, handlers , **settings)

if __name__ == '__main__':
    import logging
    logging.getLogger().setLevel(logging.DEBUG)

    tornadio.server.SocketServer( Application() )